package com.sky.mapper;

import com.sky.entity.OrderDetail;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Set;

@Mapper
@Component
public interface OrderDetailMapper {

    @Select("select * from order_detail where order_id = #{orderid}")
    List<OrderDetail> selectByOrderId(Long orderid);

    @Select(" select * from order_detail ")
    List<OrderDetail> selectByAll();

    @Insert("insert into order_detail (name, image, order_id, dish_id, setmeal_id, dish_flavor, number, amount) " +
            "value(#{name}, #{image}, #{orderId}, #{dishId}, #{setmealId}, #{dishFlavor}, #{number}, #{amount})")
    void save(OrderDetail orderDetail);

    /**
     * 批量插入订单明细数据
     * @param orderDetails
     */
    void insertBatch(List<OrderDetail> orderDetails);


    List<OrderDetail> getHistoryOrders(Set<Long> orderIds);
}
